package com.stu.tools.easyexcle.read;

import com.alibaba.excel.EasyExcel;
import com.stu.service.ExcelService;
import com.stu.vo.ExcelData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ReadTest {
    @Autowired
    private ExcelService excelService;
    public  void simpleRead() {
        // 写法1：
//        String fileName = TestFileUtil.getPath() + "demo" + File.separator + "stduentsMod.xlsx";
        String fileName = "d:\\files\\studentsMod.xlsx";
        // 这里 需要指定读用哪个class去读，然后读取第一个sheet 文件流会自动关闭
        EasyExcel.read(fileName, ExcelData.class, new DemoDataListener( excelService)).sheet().doRead();
    }
}
